package com.kris.dev2;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

public class Thread1 {

	
	
	public static void main(String[] args) {
		
		HashMap<String, Object> map = new HashMap<String, Object>();
		map.put(null, null);
		map.put(null, "1");
		map.put(null, "2");
		
		map.put("1",null);
		map.put("2",null);
		
		// foreach遍历map
		for (String key : map.keySet()) {
			System.out.println(key);
		}
		for (Object value : map.values()) {
			System.out.println(value);
		}
		System.out.println("==========================");
		
		// 遍历map
		for(Map.Entry<String, Object> entry:map.entrySet()){
			System.out.println("entry 打印key:"+entry.getKey());// key只能一个为null
			System.out.println("entry 打印value:"+entry.getValue());
		}
		System.out.println("==========================");
		
		// iterator遍历 map
		Iterator<Map.Entry<String, Object>> entrys = map.entrySet().iterator();
		while(entrys.hasNext()){
			Map.Entry<String, Object> entry = entrys.next();
			System.out.println("iterator key:"+entry.getKey());
			System.out.println("iterator value"+entry.getValue());
		}
	}
}
